package bishi.day05_4_22;

import java.util.Scanner;

//连续数组最大和
public class maxArray {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for(int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            int max = arr[0];
            for(int i = 1; i < n; i++) {
                arr[i] = Math.max(arr[i],arr[i] + arr[i - 1]);
                max = Math.max(arr[i],max);
            }
            System.out.println(max);
        }
    }
}
